Class TreeNode<T extends TreeNodeInfo>

  • All Implemented Interfaces:
    java.lang.Comparable<TreeNode>

    public class TreeNode<T extends TreeNodeInfo>
    extends java.lang.Object
    implements java.lang.Comparable<TreeNode>
    The basic unit of the BinarySearchTree.
    • Constructor Detail

      • TreeNode

        public TreeNode()
      • TreeNode

        public TreeNode​(T info)
        Create an empty TreeNode.
        Parameters:
        info - the information
    • Method Detail

      • getInfo

        public T getInfo()
      • getLeftChild

        public TreeNode getLeftChild()
        Get the left child TreeNode.
        Returns:
        the left child TreeNode
      • getRightChild

        public TreeNode getRightChild()
        Get the right child TreeNode.
        Returns:
        the right child TreeNode
      • setNode

        public void setNode​(T info,
                            TreeNode<T> l,
                            TreeNode<T> r)
        Set all the information of this TreeNode.
        Parameters:
        info - the information
        l - the left child TreeNode
        r - the right child TreeNode
      • setInfo

        public void setInfo​(T info)
        Set the information of this TreeNode.
        Parameters:
        info - the info to set
      • setLeftChild

        public void setLeftChild​(TreeNode left)
        Set the left child TreeNode.
        Parameters:
        left - the left child TreeNode
      • setRightChild

        public void setRightChild​(TreeNode right)
        Set the right child TreeNode.
        Parameters:
        right - the right child TreeNode
      • compareTo

        public int compareTo​(TreeNode that)
        Specified by:
        compareTo in interface java.lang.Comparable<T extends TreeNodeInfo>
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object